Example
Column A B
1 *
2
3
* This cell is shaded blue, therefore B1 automatically detects it as
being blue and fills B1 with the text "BLUE"
Please Help
open your Visual Basic Editor (Alt+F11)
add a new module to your project ( from the VBE menu select [Insert]/[Module]
and paste in the following code
Const Red = vbRed
Const Blue = vbBlue
Const Green = vbGreen
Const Yellow = vbYellow
Sub PasteColors()
Dim intColor As Integer
For i = 0 To 15
Cells(i + 5, 5).Interior.Color = Choose(Int(Rnd() * 4) + 1, Red, Blue,
Green, Yellow)
Next
End Sub
Function ShowColor(rCell As Range) As String
Dim s As String
Select Case rCell.Interior.Color
Case Red: s = "Red"
Case Blue: s = "Blue"
Case Green: s = "Green"
Case Yellow: s = "Yellow"
Case Else: s = ""
End Select
ShowColor = s
End Function
The subroutine is just a tester - it simply randomly colors 15 cells in a
column to one of 4 basic colors. There are of course more - but you can do the
rest for yourself !
run this sub. Now got to the spreadsheet and in a cell to the right of the
column of colors - ie cell F5 type in this: =ShowColor(E5) then copy it down
to F20 You'll see that the function checks the color of the cell reference
passed to it (ie cells in the nect left column) and returns its color.
Hope that this gives you some ideas
Regards
Patrick
_________________________________________
In article <371CDFDF...@cwcom.net>,
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own